<%! func Block(w io.Writer,r *http.Request,q string,filter string,from int,size int,config *common.UIConfig, response *index.SearchResponse) error %>
<%% import "net/http" %%>
<%% import "github.com/infinitbyte/gopa/ui/search/common" %%>
<%% import "github.com/infinitbyte/framework/core/index" %%>
<%% import "github.com/infinitbyte/framework/core/util" %%>
<%% import "fmt" %%>

<% if len(response.Hits.Hits)>0 { %>

    <%
    for seq,hit:=range response.Hits.Hits{
    url:=common.SafeGetField(hit.Source["snapshot"].(map[string]interface{})["url"],"N/A")
    snapshotId:=common.SafeGetField(hit.Source["snapshot"].(map[string]interface{})["id"],"")
    screenshot:=common.SafeGetField(hit.Source["task"].(map[string]interface{})["last_screenshot_id"],"")
    title:=common.SmartGetField(hit.Highlight["snapshot.title"],hit.Source["snapshot"].(map[string]interface{})["title"],"N/A")
    summary:=util.SubStringWithSuffix(common.SmartGetField(hit.Highlight["snapshot.text"],hit.Source["snapshot"].(map[string]interface{})["text"],"N/A"),300,"...")
    %>
<TABLE data-id=result_<%= seq %> class=result cellSpacing=0 cellPadding=0> <TBODY><TR>
<TD class=f>
    <H3 class=t><A  title='<%= hit.Source["snapshot"].(map[string]interface{})["title"] %>' href="<%= url %>"  target=_blank>
        <%== util.SubStringWithSuffix(title,500,"...") %></A> </H3>
    <FONT size=-1><% if(screenshot!=""){ %>
        <img class="screenshot" src="/screenshot/<%== screenshot %>" class="uk-icon-hover uk-icon-history" />
        <% } %>
        <%== summary %> <BR>
        <div  class=g><a target=_blank href="<%= url %>"><%=util.SubStringWithSuffix(url,80,"...") %></a>
            <% if(snapshotId!=""){ %>
            <a target="_blank" href="/snapshot/<%== snapshotId %>" class="uk-icon-hover uk-icon-history"></a>
            <% } %>
        </div>
    </FONT>
</TD>
</TR></TBODY>
</TABLE>
<%
}} %>

